#ifndef _STRAWGUI_ENGINE_H_
#define _STRAWGUI_ENGINE_H_

#include "sTexture.h"
#include "sTextureResource.h"
#include "sFont.h"
#include "sFontResource.h"
#include "sDrawContext.h"
#include "sRenderTarget.h"
#include "sDrawSurface.h"
#include "sObserver.h"

#include "sMath.h"
#include "DataBase.h"

#define ALLOC_CONTEXT(guiEngine, context, ...) sgui::engine::sDrawContext* context = (sgui::engine::sDrawContext*)alloca(guiEngine.getContextMemorySize()); \
	guiEngine.getContext(context, __VA_ARGS__);
#define RELEASE_CONTEXT(context) context->sgui::engine::sDrawContext::~sDrawContext();

namespace sgui
{
namespace engine
{
	class sEngine : public sDrawSurface, public obs::sSubject
	{
	public:
		virtual sTexture* getTexture(const res::sTextureResource& res, const preset::sTexturePreset& preset) = 0;
        virtual sFont* getFont(const res::sFontResource& res, const preset::sFontPreset& preset) = 0;
		virtual sRenderTarget* getRenderTarget(const math::sPointf& size) = 0;

		virtual void getContext(void *memory, const math::sRectf& rect, bool clipRect = true) const = 0;
		virtual void getContext(void *memory, const math::sRectf& rect, const sDrawContext* parentContext, bool clipRect = true) const = 0;
		virtual u32 getContextMemorySize() const = 0;

		virtual void update(double dt) = 0;
		virtual math::sPointf retreiveScreenSize() const = 0;

		virtual void textBeginRead() = 0;
		virtual void textEndRead() = 0;

		void init()
		{
			setSurfaceSize(retreiveScreenSize());
		}

		virtual void drawRect(const math::sRectf& rect, 
            u32 color = 0xFFFFFFFF, bool fill = false) const = 0;
	};
};
};

#endif